﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using GavinCMS.Model;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System.Data;
using System.Data.Common;

namespace GavinCMS.DAL
{
    public class ProductsDAL
    {
        public IList<Products> GetProducts()
        {

            DatabaseProviderFactory factory = new DatabaseProviderFactory();
            //Database db = factory.Create("AdventureWorks2012");
            Database db = factory.CreateDefault();

            DbCommand cmd = db.GetSqlStringCommand("select * from Production.Product where MakeFlag=@MakeFlag");
            db.AddInParameter(cmd,"@MakeFlag",DbType.Boolean,true);
            DataSet ds = db.ExecuteDataSet(cmd);

            var productsList = Gavin.Common.dbhelper.DataSetIList.DataSetToIList<Products>(ds, 0);

            return productsList;
        }
    }
}
